package cn.iocoder.yudao.module.javainfo.service.userpet;

import cn.hutool.core.collection.CollUtil;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.transaction.annotation.Transactional;

import java.util.*;
import cn.iocoder.yudao.module.javainfo.controller.admin.userpet.vo.*;
import cn.iocoder.yudao.module.javainfo.dal.dataobject.userpet.UserPetDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;

import cn.iocoder.yudao.module.javainfo.dal.mysql.userpet.UserPetMapper;

import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.diffList;
import static cn.iocoder.yudao.module.javainfo.enums.ErrorCodeConstants.*;

/**
 * 用户宠物关联 Service 实现类
 *
 * @author 爪哇国大BOSS
 */
@Service
@Validated
public class UserPetServiceImpl implements UserPetService {

    @Resource
    private UserPetMapper userPetMapper;

    @Override
    public Long createUserPet(UserPetSaveReqVO createReqVO) {
        // 插入
        UserPetDO userPet = BeanUtils.toBean(createReqVO, UserPetDO.class);
        userPetMapper.insert(userPet);

        // 返回
        return userPet.getId();
    }

    @Override
    public void updateUserPet(UserPetSaveReqVO updateReqVO) {
        // 更新
        UserPetDO updateObj = BeanUtils.toBean(updateReqVO, UserPetDO.class);
        userPetMapper.updateById(updateObj);
    }

    @Override
    public void deleteUserPet(Long id) {
        // 删除
        userPetMapper.deleteById(id);
    }

    @Override
        public void deleteUserPetListByIds(List<Long> ids) {
        // 删除
        userPetMapper.deleteByIds(ids);
        }

    @Override
    public UserPetDO getUserPet(Long id) {
        return userPetMapper.selectById(id);
    }

    @Override
    public UserPetDO getUserPetByPetId(Long id) {
        return userPetMapper.selectByPetId(id);
    }

    @Override
    public PageResult<UserPetDO> getUserPetPage(UserPetPageReqVO pageReqVO) {
        return userPetMapper.selectPage(pageReqVO);
    }

    @Override
    public void deleteUserPetById(Long id) {
        userPetMapper.deleteByPetId(id);
    }

    @Override
    public void deleteUserPetListByPetIds(List<Long> ids) {
        userPetMapper.deleteByPetIds(ids);
    }

}